package com.lx.demo2;

import jakarta.servlet.annotation.WebListener;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;

@WebListener("/s2")
public class Listener implements HttpSessionListener {
    private static int cnt = 0;
    public void sessionCreated(HttpSessionEvent se) {
        cnt++;
        se.getSession().getServletContext().setAttribute("cnt", cnt);
    }
    public void sessionDestroyed(HttpSessionEvent se) {
        cnt--;
        se.getSession().getServletContext().setAttribute("cnt", cnt);
    }
}
